package com.stu.facade.service;

import java.util.ArrayList;
import java.util.List;

import com.stu.entity.service.TechnologyBlog;
import com.stu.facade.base.BaseFacade;
import com.stu.utils.BeanUtils;

public class TechnologyBlogFacade extends BaseFacade<TechnologyBlog> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String title;
	private String subtitle;
	private String content;
	
	
	// facade 
	private String userId;
	private String userNickName;
	
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getSubtitle() {
		return subtitle;
	}
	public void setSubtitle(String subtitle) {
		this.subtitle = subtitle;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserNickName() {
		return userNickName;
	}
	public void setUserNickName(String userNickName) {
		this.userNickName = userNickName;
	} 
	
	public void getFacade(TechnologyBlog b) throws Exception{
		if(null!=b.getUser()){ 
			BeanUtils.copyBean2(this,b);  
			this.setUuid(b.getUuid());
			this.setCreateTime(b.getCreateTime()+"");;
			this.setUserId(b.getUser().getUuid());
			this.setUserNickName(b.getUser().getNickname());
		} 
	}
	
	
	public static List<TechnologyBlogFacade> getFacadeList(List<TechnologyBlog>blogList){
		List<TechnologyBlogFacade>list=new ArrayList<TechnologyBlogFacade>();
		TechnologyBlogFacade f=null;
		for(int i=0;blogList!=null&&i<blogList.size();i++){
			TechnologyBlog b=blogList.get(i);
			f=new TechnologyBlogFacade();
			try {
				f.getFacade(b);
			} catch (Exception e) {
				e.printStackTrace();
			} 
			list.add(f);
		}
		return list;
	}
	
	
	
}
